/**
 * Created by smp on 2017/3/16.
 */
//加载权限组下拉列表
$.ajax({
    url:ROOT_PATH + '/permission/authorityGroup/getAuthorityGroupList.shtml',
    type:"post",
    dataType:"json",
    success:function(data){
        $('#groupList').combobox({
            data:data,
            valueField:'id',
            textField:'name',
            value:null
            
        });
    }
});
//表单提交
$('#saveAuthority').on('click',function () {
    layer.confirm('是否确定保存？', {
        btn: ['确定','取消'] //按钮
    }, function(){
        $.ajax({
            type: "POST",
            url: ROOT_PATH+'/permission/authority/add.shtml',
            data: $("#athorityForm").serialize(),
            dataType: "json",
            success: function(result){
                if (result.success) {
                    layer.msg('保存成功', {
                        icon: 1,
                        time: 1000 //2秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        var indexp = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(indexp); //再执行关闭
                    });
                    parent.$('#authorityList').datagrid('load');
                }
                else {
                    layer.msg('保存失败', {
                        icon: 2,
                        time: 1000
                    });
                }
            }
        });
    });

});
//参数清空
$('#ResetForm').on('click',function () {
    $('#athorityForm').form('reset');
});
